package cn.com.oceansoft.business.szjf.service.impl;

import cn.com.oceansoft.business.base.entity.Pager;
import cn.com.oceansoft.business.base.entity.Query;
import cn.com.oceansoft.business.log.persistence.ISysOperLogMapper;
import cn.com.oceansoft.business.szjf.entity.CheckInfo;
import cn.com.oceansoft.business.szjf.entity.Logmanage;
import cn.com.oceansoft.business.szjf.entity.Yssh;
import cn.com.oceansoft.business.szjf.persistence.IExpertMapper;
import cn.com.oceansoft.business.szjf.persistence.IYsshMapper;
import cn.com.oceansoft.business.szjf.service.IYsshService;
import cn.com.oceansoft.nos.common.util.web.PageUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

/**
 * Created by Administrator on 2017/6/26.
 */
@Service
@Transactional
public class YsshService implements IYsshService {

    @Resource
    private IYsshMapper ysshMapper;
    @Resource
    private ISysOperLogMapper sysOperLogMapper;
    @Resource
    private IExpertMapper expertMapper;
    @Override
    public Pager<Yssh> findYsshByPage(Query query) {
        PageHelper.startPage(query.getPageNum(), query.getNumPerPage(), true);
        Page<Yssh> page = ysshMapper.getYsshByPage((Yssh)query.getObj());
        return PageUtil.page2pager(page, query);
    }

    @Override
    @Transactional(readOnly = false, rollbackFor = Exception.class)
    public void updateStatusByGuid(Logmanage log,Yssh yssh, CheckInfo info) {
        sysOperLogMapper.insertLog(log);
        ysshMapper.updateStatusByGuid(yssh);
        expertMapper.insertCheckInfo(info);
    }

    @Override
    public void updateObjByGuid(Yssh yssh) {
        ysshMapper.updateObjByGuid(yssh);
    }

    @Override
    public Yssh getObjByGuid(String paguid) {
        return ysshMapper.getObjByGuid(paguid);
    }
}
